{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# sympy基础使用"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 内置的特殊函数\n",
    "\n",
    "对于一些常用的函数，sympy将其集成在了内部，如cos、sin、log、sqrt、Gamma等，导入后即可使用（这点和scipy一样）\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 积分计算\n",
    "在sympy中有用多种方式来计算积分：累积求和、原函数求积分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'values' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_12868/2659614095.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m     13\u001b[0m \u001b[0mE\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mDerivative\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mF\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m-\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     14\u001b[0m \u001b[0mF1\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdsolve\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mE\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mF\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mics\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m{\u001b[0m\u001b[0mF\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 15\u001b[1;33m \u001b[0ma\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mF1\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msubs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mevalf\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msubs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mvalues\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     16\u001b[0m \u001b[0mb\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mF1\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msubs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m0.1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mevalf\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     17\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'values' is not defined"
     ]
    }
   ],
   "source": [
    "from sympy import var,Sum,Integral,oo\n",
    "from sympy import Derivative, dsolve\n",
    "from sympy import Function\n",
    "f, x = var('f x')\n",
    "f = 1/x\n",
    "\n",
    "result1 = Integral(f, (x, 1e-50, 1)).evalf(50)\n",
    "result2 = Integral(f, (x, 1,-oo)).evalf(40)\n",
    "Integral(1/x, (x, 1, +oo))\n",
    "\n",
    "# 求原函数\n",
    "F = Function('F')\n",
    "E = Derivative(F(x),(x, 1)) - 1/x\n",
    "F1 = dsolve(E, F(x), ics={F(1):0})\n",
    "a = F1.subs(x, 1).evalf(subs=values)\n",
    "b = F1.subs(x, 0.1).evalf()\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAD4CAYAAAAJmJb0AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAyUUlEQVR4nO3de3xU9Zn48c8zkxuXcAkg4RaCyB0EJOuFWgOIiK1b2+oK3tfu4nZ/7dbaapTq7s/efvW3ra11u62K11UraKnVYr3B6qo/rTbgBRARys0AgRi5BJKQzMzz++PMJGeSmWSumWTyvF8vXpw5czLnO5B5znee73O+X1FVjDHGZCdPphtgjDEmfSzIG2NMFrMgb4wxWcyCvDHGZDEL8sYYk8VyMt0At6FDh2ppaWmmm2GMMT3K+vXrP1XVYZGe61ZBvrS0lMrKykw3wxhjehQR2R3tOUvXGGNMFrMgb4wxWcyCvDHGZLFulZM3xphkNDc3U1VVRWNjY6abkhYFBQWMHj2a3NzcmH/GgrwxJmtUVVVRWFhIaWkpIpLp5qSUqlJbW0tVVRXjxo2L+ed6fpC/52yo3th+f/EM+PobXd8eY0zGNDY2ZmWABxARhgwZQk1NTVw/1/Nz8qNPB29e+D5vnrPfGNPrZGOAD0n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qtVd2MQOdfR/ACAi1wAXAud2twtsFFXAGNfj0cC+DLUlYSKSixPgH1fV32e6PXH6HPAlEfkCUAAMEJHHVPXKDLcrHlVAlaqGvkH9DifIp11vStf8AVgAICITgTx60Gx2qrpRVU9S1VJVLcX5pTmtOwX4zojIYuBm4EuqWp/p9sToL8AEERknInnAUuDZDLcpLuL0Ch4AtqjqzzPdnnip6nJVHR38vV8K/HcPC/AEP6efiMik4K5zgQ+74txZ1ZPvxIPAgyKyCWgCrukhPcls8isgH3g5+G3kz6r69cw2qWOq6hORbwIvAl7gQVXdnOFmxetzwFXARhF5L7jve6r6p8w1qVf6F+DxYGdhB3BtV5zUpjUwxpgs1pvSNcYY0+tYkDfGmCxmQd4YY7KYBXljjMliFuSNMSaLWZA3xpgsZkHeGGOy2P8HLAlstCKfyqIAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#程序文件Pex3_16.py\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "def fac(n): return (1 if n<1 else n*fac(n-1))\n",
    "def item(n,x): return (-1)**n*x**(2*n+1)/fac(2*n+1)\n",
    "def mysin(n,x): return (0 if n<0 else mysin(n-1,x)+item(n,x))\n",
    "x=np.linspace(-2*np.pi,2*np.pi,101)\n",
    "plt.plot(x,np.sin(x),'*-')\n",
    "str=['v-','H--','-.']\n",
    "for n in [1,2,3]: plt.plot(x,mysin(2*n-1,x),str[n-1])\n",
    "plt.legend(['sin','n=1','n=3','n=5'])\n",
    "plt.savefig('figure3_16.png',dpi=500); plt.show()\n"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "a17d8fbc39f154724391315e19256412600de31bba27aef41cfe960effe5852b"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 ('SciencePy')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
